home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- *
- * @@@BUILDINFO@@@ 01startup.jsx 1.0.0.50 17-Feb-2005
- * Copyright 2005 Adobe Systems Incorporated
- * All Rights Reserved.
- *
- * NOTICE: All information contained herein is, and remains the property of
- * Adobe Systems Incorporated and its suppliers, if any. The intellectual
- * and technical concepts contained herein are proprietary to Adobe Systems
- * Incorporated and its suppliers and may be covered by U.S. and Foreign
- * Patents,patents in process,and are protected by trade secret or copyright
- * law. Dissemination of this information or reproduction of this material
- * is strictly forbidden unless prior written permission is obtained from
- * Adobe Systems Incorporated.
- **************************************************************************/
-
- // enable very simple message logging
-
- BridgeTalk.log = false;
-
- // Initialzie the JavaScript environment during startup.
-
- app.onStartup = function (shiftPressed)
- {
- // Load the known apps into the main window's apps listbox
- window.loadApps();
- // Create the own debugger
- Debugger.createOwn();
-
- // Load the preferences file if present and SHIFT has not been pressed.
- // This file has been defined by writePrefs() during app shutdown.
- var prefsLoaded = false;
- if (!shiftPressed)
- {
- prefsLoaded = prefs.load();
- // also load the config.jsx file
- try
- {
- var config = new File (app.configFolder + "/config.jsx");
- if (config.exists)
- app.load (config);
- }
- catch (ignore) {}
- }
- // Connect the own debugger, but save the prefs target and engine
- Debugger.connect (BridgeTalk.appSpecifier);
- // wait until we are connected (should not take long)
- var then = new Date;
- while (!currentDebugger)
- {
- BridgeTalk.pump();
- var now = new Date;
- if ((now - then) > 50000)
- {
- // fatal script error, should never happen (therefore, no ZString)
- errorBox ("FATAL ERROR: Cannot initialize.\nExiting.");
- return false;
- }
- }
-
- // Setup various panes whse contents may depend on the prefs or config data.
- window.variables.setup();
-
- // At this point, also a remote connect message should have been processed.
- // The current debugger should be the one to use.
-
- if (!prefsLoaded)
- // no prefs? start with a blank document
- Document.create();
-
- // Reflect the settings in the menu
- editMenu.lines.checked = prefs.lineNumbers;
- editMenu.hilite.checked = prefs.hilite;
- debugMenu.reflectState();
- documents.setProfDisplayMode (prefs.profDisplayMode);
-
- // Create the timer function that checks for the presence of a
- // debugging target every 5 seconds
- scheduleTargetChecker();
-
- // and print the ExtendScript version
- if ($.version.indexOf ("debug") >= 0)
- print ("ExtendScript " + $.version);
-
- // If app and engine have been saved, try to switch there
- if (prefs.target && prefs.engine)
- {
- // If the current debugger is our own, and the prefs setting is not,
- // switch to that app
- if (currentDebugger == ownDebugger && prefs.target != BridgeTalk.appSpecifier)
- {
- window.selectAppAndEngine (prefs.target, prefs.engine);
- if (prefs.target && BridgeTalk.launchTarget (prefs.target))
- Debugger.connect (prefs.target);
- }
- }
- return true;
- }
-
- // Create or reschedule the target checker task
-
- var taskID = 0; // the task ID
-
- function scheduleTargetChecker (seconds)
- {
- if (!seconds)
- seconds = 2;
- if (taskID)
- app.cancelTask (taskID);
- taskID = app.scheduleTask ("BridgeTalk.checkTargets()", seconds * 1000, true);
- }
-
- // Global Alert box that is localizable and displays an error title
-
- function messageBox (msg)
- {
- if (msg [0] == "$")
- msg = localize.apply (this, arguments);
- alert (msg, window.title);
- }
-
- // Global Error box that is localizable and displays an error title
-
- function errorBox (msg)
- {
- var target = window.title;
- if (currentDebugger && currentDebugger.active)
- target = BridgeTalk.getDisplayName (currentDebugger.target);
- var title = localize ("$$$/ESToolkit/Alerts/ErrorTitle=%1 Error", target);
- if (msg [0] == "$")
- msg = localize.apply (this, arguments);
- alert (msg, title, true);
- }
-
- // Global Confirm box that is localizable and displays the right title
-
- function queryBox (msg)
- {
- var target = window.title;
- if (currentDebugger)
- target = BridgeTalk.getDisplayName (currentDebugger.target);
- var title = localize ("$$$/ESToolkit/Alerts/ErrorTitle=%1 Error", target);
- if (msg [0] == "$")
- msg = localize.apply (this, arguments);
- return confirm (msg, false, target);
- }
-
-